-
Notifications
You must be signed in to change notification settings - Fork 83k
Improve macOS Icon pattern to avoid line-ending corruption #4753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
silentip404
wants to merge
1
commit into
github:main
Choose a base branch
from
silentip404:improve-macos-icon-pattern
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replace invisible CR with character class Icon[^!-~] The literal CR character is frequently corrupted by: - Text editors auto-trimming invisible chars - Formatting tools (editorconfig) normalizing line endings - Copy/paste operations losing special characters - IDE auto-formatting and linting tools Character class pattern is collaboration-safe and functionally identical.
Author
======================================
Icon[^!-~] Full Validation Test
======================================
📝 Creating test files...
✓ Creating control character files (should be ignored):
- Icon\r (CR-13) ← target file
- Icon\t (TAB-9)
- Icon\n (LF-10)
- Icon\f (FF-12)
- Icon\x1B (ESC-27)
- Icon space (SP-32)
- Icon\x7F (DEL-127)
✓ Creating printable character files (should not be ignored):
- Icon! (boundary-33)
- Icon" (34)
- Icon# (35)
- Icon$ (36)
- Icon~ (boundary-126)
- Icon.png
- Icon.svg
- Icon.ico
- Icon.icns
- Icona
- Icon1
- Icon123
- IconSet
- Icon_old
- Icon-new
- Icon.backup
- MyIcon
- icon.png (lowercase)
✓ Creating multi-character test files:
- Icon\r\r (double carriage return)
- Icon\r\n (Windows line ending)
📋 File list (with byte display):
Icon\t
Icon\n
Icon\f
Icon\r
Icon\r\n
Icon\r\r
Icon\033
Icon
Icon!
Icon\"
Icon#
Icon$
Icon-new
Icon.backup
Icon.icns
Icon.ico
Icon.png
Icon.svg
Icon1
Icon123
IconSet
Icon_old
Icona
Icon~
Icon\177
MyIcon
🔍 Inspecting byte code of Icon\r:
00000000: 4963 6f6e 0d Icon.
======================================
Begin testing gitignore rule
======================================
[Test 1] Files that should be ignored (control characters):
--------------------------------------
✅ Icon\r (CR-13) correctly ignored
✅ Icon\t (TAB-9) correctly ignored
✅ Icon\n (LF-10) correctly ignored
✅ Icon\f (FF-12) correctly ignored
✅ Icon\x1B (ESC-27) correctly ignored
✅ Icon space (SP-32) correctly ignored
✅ Icon\x7F (DEL-127) correctly ignored
[Test 2] Files that should not be ignored (printable characters):
--------------------------------------
✅ Icon! (boundary-33) not ignored
✅ Icon" (34) not ignored
✅ Icon# (35) not ignored
✅ Icon~ (boundary-126) not ignored
✅ Icon.png not ignored
✅ Icon.svg not ignored
✅ Icona not ignored
✅ Icon1 not ignored
✅ Icon123 not ignored
✅ IconSet not ignored
✅ Icon_old not ignored
✅ Icon-new not ignored
✅ MyIcon not ignored
✅ icon.png (lowercase) not ignored
[Test 3] Multi-character boundary cases:
--------------------------------------
✅ Icon\r\r (should not match) not ignored
✅ Icon\r\n (should not match) not ignored
[Test 4] git check-ignore -v detailed check:
--------------------------------------
.gitignore:1:Icon[^!-~] "Icon\r"
======================================
Test summary
======================================
✅ All tests passed! Icon[^!-~] rule works as expected
Validation summary:
✓ Icon\r (macOS Icon file) correctly ignored
✓ All control character files ignored
✓ All normal files unaffected
✓ Boundary characters (!, ~) handled correctly |
|
Ued7ed7ee7e7e7eeuee7euesueueueueueu4
[Dorian Gurazdowski - Chat @ Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=3did87) [3did87]
On November 10, 2025 at 19:32 GMT, silentip404 ***@***.***> wrote:
silentip404 left a comment [(github/gitignore#4753)](#4753 (comment))
====================================== Icon[^!-~] Full Validation Test ====================================== 📝 Creating test files... ✓ Creating control character files (should be ignored): - Icon\r (CR-13) ← target file - Icon\t (TAB-9) - Icon\n (LF-10) - Icon\f (FF-12) - Icon\x1B (ESC-27) - Icon space (SP-32) - Icon\x7F (DEL-127) ✓ Creating printable character files (should not be ignored): - Icon! (boundary-33) - Icon" (34) - Icon# (35) - Icon$ (36) - Icon~ (boundary-126) - Icon.png - Icon.svg - Icon.ico - Icon.icns - Icona - Icon1 - Icon123 - IconSet - Icon_old - Icon-new - Icon.backup - MyIcon - icon.png (lowercase) ✓ Creating multi-character test files: - Icon\r\r (double carriage return) - Icon\r\n (Windows line ending) 📋 File list (with byte display): Icon\t Icon\n Icon\f Icon\r Icon\r\n Icon\r\r Icon\033 Icon Icon! Icon\" Icon# Icon$ Icon-new Icon.backup Icon.icns Icon.ico Icon.png Icon.svg Icon1 Icon123 IconSet Icon_old Icona Icon~ Icon\177 MyIcon 🔍 Inspecting byte code of Icon\r: 00000000: 4963 6f6e 0d Icon. ====================================== Begin testing gitignore rule ====================================== [Test 1] Files that should be ignored (control characters): -------------------------------------- ✅ Icon\r (CR-13) correctly ignored ✅ Icon\t (TAB-9) correctly ignored ✅ Icon\n (LF-10) correctly ignored ✅ Icon\f (FF-12) correctly ignored ✅ Icon\x1B (ESC-27) correctly ignored ✅ Icon space (SP-32) correctly ignored ✅ Icon\x7F (DEL-127) correctly ignored [Test 2] Files that should not be ignored (printable characters): -------------------------------------- ✅ Icon! (boundary-33) not ignored ✅ Icon" (34) not ignored ✅ Icon# (35) not ignored ✅ Icon~ (boundary-126) not ignored ✅ Icon.png not ignored ✅ Icon.svg not ignored ✅ Icona not ignored ✅ Icon1 not ignored ✅ Icon123 not ignored ✅ IconSet not ignored ✅ Icon_old not ignored ✅ Icon-new not ignored ✅ MyIcon not ignored ✅ icon.png (lowercase) not ignored [Test 3] Multi-character boundary cases: -------------------------------------- ✅ Icon\r\r (should not match) not ignored ✅ Icon\r\n (should not match) not ignored [Test 4] git check-ignore -v detailed check: -------------------------------------- .gitignore:1:Icon[^!-~] "Icon\r" ====================================== Test summary ====================================== ✅ All tests passed! Icon[^!-~] rule works as expected Validation summary: ✓ Icon\r (macOS Icon file) correctly ignored ✓ All control character files ignored ✓ All normal files unaffected ✓ Boundary characters (!, ~) handled correctly
—
Reply to this email directly, [view it on GitHub](#4753 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/BWBQRBMIN4U67TWMMFJSSBT34DR4VAVCNFSM6AAAAACLVLW2F2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMJTGUZTCMZSGM).
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reasons for making this change
The current
Icon\rpattern in macOS.gitignore has a reliability issue: the invisible carriage return (CR) character is silently corrupted by editors' default behavior, causing the rule to fail even when developers believe they haven't modified the file.Core Problem: Silent Line-Ending Conversion
The literal
\rcharacter in the.gitignorefile is automatically processed by modern editors during save operations, even when file content is ultimately unchanged.Actual corruption observed (real git diff output):
What happened:
Iconfollowed by carriage return (displayed as^Min some environments)\n), splitting the pattern into two linesIcon[+ new line], completely brokenIcon\rfiles are no longer matched and start appearing ingit statusPrecise Reproduction Steps (Verified)
Test Environment:
Global/macOS.gitignoreReproduction Steps:
.gitignorefile containing theIcon\rrulegit diffExpected Result:
Actual Result:
Icon\ris split into two linesAnalysis:
\r→\nduring the first saveWhy This Is a Serious Problem
High stealth:
\rcharacter caused the issueWide impact:
No error indication:
Solution: Use Character Class Pattern
Replace
Icon\rwithIcon[^!-~](Icon followed by any non-printable character):Technical Rationale:
[^!-~]matches all characters outside the ASCII printable range (33-126)Why This Works:
[^!-~]contains only printable characters and won't be modified by editors' line-ending normalizationIcon\r)Backward Compatibility:
Icon\rfilesIcon + any control charactercombinationsIcon\rfilesIcon.png,IconSet,Icon!,Icon123etc. are explicitly excluded!(ASCII 33) to~(ASCII 126) defines the printable character range boundaryWhy Character Class Is the Best Solution
Comparison of possible approaches:
Icon\rIcon[\r]\rinside brackets is still a literal byte, will be converted the same wayIcon?Icon1,Iconaand other normal filesIcon*Icon[^!-~]Links to documentation supporting these rule changes
N/A - This change fixes an editor compatibility issue discovered through testing. The pattern syntax is standard gitignore format documented in the Git documentation.
If this is a new template
N/A - This PR modifies an existing template (
Global/macOS.gitignore), not adding a new one.Merge and Approval Steps